﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Muel.TypeScriptFacade.Core
{
    public class TypeScriptParameterCollection : Dictionary<string, TypeScriptType>
    {
        public override string ToString()
        {
            return ToTypeScriptParameterList();
        }

        #region Output to TypeScript

        private const string parameterValueFormat = @"                '{0}' : {1}";

        internal string ToTypeScriptParameterList()
        {
            return (this.Count == 0) ?
                string.Empty
                :
                string.Join(string.Empty, this.Select(kvp => string.Format("{0}: {1}, ", kvp.Key, kvp.Value.GetTypeScriptType())));
        }

        internal string ToTypeScriptObject()
        {
            string parameterNameValueList = string.Join(", " + Environment.NewLine, 
                this.Select(kvp => string.Format(parameterValueFormat, kvp.Key, kvp.Key)));

            return parameterNameValueList;
        }

        #endregion
    }
}
